<#import "../tpl/pageTep.ftl" as page>
<@page.pageBase currentMenu="分销仓库">
<style>
    #title {
        margin-top: 6px;
        margin-left: -10px;
    }
</style>
<!--suppress ALL -->
<form id="searchForm" class="form-panel" action="${basepath}/rest/manage/entrepot/loadData" >
    <ul class="panel-content">
        <li>
            <div class="control-group span5">
                <div class="search-controls  controls">
                    <input type="text" name="storeName" id="title" value="" placeholder="搜索分销商">
                </div>
            </div>
            <div class="form-actions span2">
                <button type="submit" class="button  button-primary">
                    搜索
                </button>
            </div>
        </li>
    </ul>
</form>
<div id="grid"></div>
<script>
    var Grid = BUI.Grid,
            Store = BUI.Data.Store,
            columns = [
                {title: '序号', dataIndex: 'userID', elCls: 'center', width: '25%'},
                {title: '分销商', dataIndex: 'storeName', elCls: 'center', width: '25%',renderer:function(value,data){
                    if(value==null||value==""){
                        return '<span>'+data.nickname+'的小店</span>';
                    }else{
                        return '<span>'+value+'</span>';
                    }
                }},
                {title: '已提货', dataIndex: 'sendNum', elCls: 'center', width: '25%',renderer:function(value,data){
                    return '<a href="${basepath}/rest/manage/entrepot/toSendDetail?userID='+data.userID+'">'+value+'</a>';
                }},
                {title: '待提货', dataIndex: 'stayNum', elCls: 'center', width: '25%',renderer:function(value,data){
                    return '<a href="${basepath}/rest/manage/entrepot/toStayDetail?userID='+data.userID+'">'+value+'</a>';
                }}
            ];

    var store = new Store({
                url : '/rest/manage/entrepot/loadData',
                autoLoad:true, //自动加载数据
                params : { //配置初始请求的参数
                    length : '10'
                },
                pageSize:10,	// 配置分页数目
                root : 'list',
                totalProperty : 'total'
            }),
            grid = new Grid.Grid({
                render:'#grid',
                columns : columns,
                loadMask: true, //加载数据时显示屏蔽层
                store: store,
                plugins : [Grid.Plugins.CheckSelection], // 插件形式引入多选表格
                // 底部工具栏
                bbar:{
                    pagingBar:true
                }
            });
    grid.render();

    //搜索框表单
    var form = new BUI.Form.HForm({
        srcNode: '#searchForm'
    }).render();

    form.on('beforesubmit', function (ev) {
        //序列化成对象
        var obj = form.serializeToObject();
        obj.start = 0; //返回第一页
        store.load(obj);
        return false;
    });
</script>

</@page.pageBase>
